package com.flushbonading.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.flushbonading.pojo.Project;
import com.flushbonading.mapper.ProjectMapper;
import com.flushbonading.pojo.dto.ProjectDTO;
import com.flushbonading.pojo.dto.ProjectListDAO;
import com.flushbonading.pojo.dto.ProjectStudentDTO;
import com.flushbonading.service.IProjectService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zlx
 * @since 2021-04-07
 */
@Service
public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> implements IProjectService {
    @Autowired
    private ProjectMapper projectMapper;
    /**
     * 项目id查询项目名
     * @param project_id
     * @return
     */
    @Override
    public String selectProjectByProject(Integer project_id) {
        QueryWrapper<Project> wrapper = new QueryWrapper<>();
        wrapper.eq("project_id",project_id);
        Project project=projectMapper.selectOne(wrapper);
        return project.getProject_name();
    }

    @Override
    public int getLastProjectID() {
        return projectMapper.getLastProjectID();
    }

    @Override
    public List<ProjectDTO> selectAll() {
        return projectMapper.selectAll();
    }

    @Override
    public int insertAProject(ProjectDTO projectDTO) {
        return projectMapper.insertAProject(projectDTO);
    }

    @Override
    public int deleteProject(int project_id) {
        return projectMapper.deleteProject(project_id);
    }

    @Override
    public int updateGroupName(int project_id, String group_name) {
        return projectMapper.updateGroupName(project_id,group_name);
    }

    @Override
    public List<ProjectStudentDTO> selectStudentByID(int project_id) {
        return projectMapper.selectStudentByID(project_id);
    }

    @Override
    public int deleteAStudent(String student_number) {
        return projectMapper.deleteAStudent(student_number);
    }

    @Override
    public int updateProject(int project_id, ProjectDTO projectDTO) {
        return projectMapper.updateProject(project_id, projectDTO);
    }

    @Override
    public String selectIntroduction(String student_number) {
        return projectMapper.selectIntroduction(student_number);
    }

    @Override
    public int updateStudent(ProjectStudentDTO projectStudentDTO, int project_id, int operating_post_id) {
        return projectMapper.updateStudent(projectStudentDTO, project_id, operating_post_id);
    }

    @Override
    public List<ProjectListDAO> selectAllProjects() {
        return projectMapper.selectAllProjects();
    }
}
